<html>
<head><meta charset="utf-8"><title>Assist Framework · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Assist.20Framework.html">Assist Framework</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="225536623"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Assist%20Framework/near/225536623" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Yoshua Wuyts <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Assist.20Framework.html#225536623">(Feb 08 2021 at 12:30)</a>:</h4>
<p>Heya; last Friday I hacked some on RA and had a lot of fun. I ended up copying and then refactoring several utility functions from other assists. E.g. in <a href="https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/assists/src/utils.rs"><code>assists/src/utils.rs</code></a>: <code>find_impl_block</code> and <code>find_struct_impl</code>.</p>
<p>I've seen other utilities in the assists lib float around, such as: <code>add_trait_assoc_items_to_impl</code>. These three all seem closely related, and it feels like we could create some structures to for example target and manipulate impl blocks. I suspect that with a bit of effort we could create structures which would make it possible to author and update assists more quickly and accurately.</p>
<p>I was wondering what the current state of thinking on this was, and whether it'd be useful to draft a quick design for this?</p>



<a name="225536763"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Assist%20Framework/near/225536763" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Yoshua Wuyts <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Assist.20Framework.html#225536763">(Feb 08 2021 at 12:31)</a>:</h4>
<p>One piece of functionality I'd like to add for example is a way to both "add a method to the start of an impl block" and "add a method to the end of an impl block". Right now the "add matches method" assist pushes new methods to the start of impl blocks, which doesn't feel right.</p>



<a name="225537103"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Assist%20Framework/near/225537103" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Assist.20Framework.html#225537103">(Feb 08 2021 at 12:34)</a>:</h4>
<p>Note that <a href="https://github.com/rust-analyzer/rust-analyzer/pull/7498/">https://github.com/rust-analyzer/rust-analyzer/pull/7498/</a> will change in a fundamental way how we write asssists. In particular, it should provide way better composability</p>



<a name="225537271"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Assist%20Framework/near/225537271" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Assist.20Framework.html#225537271">(Feb 08 2021 at 12:35)</a>:</h4>
<p>The TL;DR is that the syntax tree becomes mutable-ish, so that <code>my_impl.add_method(make::...)</code> will just work</p>



<a name="225537326"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Assist%20Framework/near/225537326" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Assist.20Framework.html#225537326">(Feb 08 2021 at 12:36)</a>:</h4>
<p>No eta on how that lands though :)</p>



<a name="225537410"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Assist%20Framework/near/225537410" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Assist.20Framework.html#225537410">(Feb 08 2021 at 12:37)</a>:</h4>
<p>Which is to say: yes, long term we need some assist framework. But at the moment the churn rate of the undrelying abstraction is high, so we don't try to go far beyound the utils module just yet.</p>



<a name="225537557"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Assist%20Framework/near/225537557" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Yoshua Wuyts <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Assist.20Framework.html#225537557">(Feb 08 2021 at 12:38)</a>:</h4>
<p>Cool! -- that sounds really good, and I'm glad I asked ^^</p>



<a name="225537764"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Assist%20Framework/near/225537764" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Yoshua Wuyts <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Assist.20Framework.html#225537764">(Feb 08 2021 at 12:40)</a>:</h4>
<p>just seeing <code>rowan</code> for the first time now; that's incredibly exciting</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>